﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Item : MonoBehaviour
{
    private Player player;
    public Prop_Type propType;//物品类型

    private void Start()
    {
        player = FindObjectOfType<Player>();
    }

    //使用
    public void Use()
    {
        if(propType==Prop_Type.HP)
        {
            player.hp += 2;
            if (player.hp > player.maxHp)
                player.hp = player.maxHp;
        }
        else
        {
            player.fireRate += 0.5f;
        }
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.gameObject.tag=="Player")
        {
            Use();
            Destroy(this.gameObject);
             
        }
    }
}
